﻿using System;
using System.Collections.Generic;
using System.Text;
using System.Data;
using System.Data.SqlClient;
using IDAL.RF.DiagnoseBottleneck;
using DBUtility;

namespace DAL.RF.DiagnoseBottleneck
{
    public class Production_ForMan:IProduction_ForMan 
    {
        protected const string PARM_STARTTIME = "@starttime";
        protected const string PARM_STOPTIME = "@stoptime";
           

        public DataSet GetProduction_Assemble(DateTime dt1, DateTime dt2)
        {
            SqlParameter[] parms = SetDTParameters(dt1, dt2);
            return sqlHelper.GetDataSet("Production_Assemble_ForMan", "Assemble", sqlHelper.ConnectionStringLocalTransaction, parms);
        }

        public DataSet GetProduction_DebugTest(DateTime dt1, DateTime dt2)
        {
            SqlParameter[] parms = SetDTParameters(dt1, dt2);
            return sqlHelper.GetDataSet("Production_DebugTest_ForMan", "DebugTest", sqlHelper.ConnectionStringLocalTransaction, parms);
        }

        public DataSet GetProduction_PackageTest(DateTime dt1, DateTime dt2)
        {
            SqlParameter[] parms = SetDTParameters(dt1, dt2);
            return sqlHelper.GetDataSet("Production_PackageTest_ForMan", "PackageTest", sqlHelper.ConnectionStringLocalTransaction, parms);
        }

        public DataSet GetProduction_Global(DateTime dt1, DateTime dt2)
        {
            SqlParameter[] parms = SetDTParameters(dt1, dt2);
            return sqlHelper.GetDataSet("Production_Global_ForMan", "Global", sqlHelper.ConnectionStringLocalTransaction, parms);
        }

        private SqlParameter[] GetDTParameters()
        {
            SqlParameter[] parms = null;
            parms = new SqlParameter[]
                {
                    new SqlParameter(PARM_STARTTIME, SqlDbType.DateTime,8),
                    new SqlParameter(PARM_STOPTIME, SqlDbType.DateTime,8),
                };
            return parms;
        }

        private SqlParameter[] SetDTParameters(DateTime dt1, DateTime dt2)
        {
            SqlParameter[] parms = GetDTParameters();
            parms[0].Value = dt1;
            parms[1].Value = dt2;
            return parms;
        }
    }
}
